package com.company.ems.controller;

import com.company.ems.dao.impl.EmployeeDAOImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/DashboardServlet")
public class DashboardServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmployeeDAOImpl employeeDAO = new EmployeeDAOImpl();
        List<?> employees = employeeDAO.findAll();
        req.setAttribute("employeeCount", employees.size()); // 传递员工总数到仪表盘
        req.getRequestDispatcher("/dashboard.jsp").forward(req, resp);
    }
}